package nowcoder.offer;

import java.util.HashSet;
import java.util.Set;

/**
 * 数组中只出现一次的数字
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-08-28 12:04
 */
public class FindNumsAppearOnce {

    public void solution(int[] array,int num1[],int num2[]){
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < array.length; i++) {
            if (set.contains(array[i])) {
                set.remove(array[i]);
            }else {
                set.add(array[i]);
            }
        }
        int i = 0;
        for (Integer s : set) {
            if (i++ == 0)
                num1[0] = s;
            else
                num2[0] = s;
        }
    }
}
